<?php
/**
 *@author Connor <caokang@foxmail.com>
 *@todo
 *@link www.zeevin.com
 */
?>
<!--main-->
<div class="warpper">
	<div class="container">
		<div class="register">
			<h1 class="tit"><?php if($_GET['type']!=1):?>标签：添加自己的标签，之嗅帮助您找到志同道合的未来伴侣。<?php else:?>排斥标签：告诉之嗅你讨厌的事物，热衷它的人将被与你隔离。<?php endif;?></h1>
			<div class="register_box">
				<div id='mytags' class="existing_label"> <strong>现有标签：</strong>
					<?php if(count($rs)>0):?>
					<?php foreach($rs as $v):?>
					<span tag="<?php echo $v[id];?>"><?php print_r($v[tag_name])?></span>
				<?php endforeach;?>
			<?php else:?>
			<span>您还未设置标签</span>
		<?php endif;?>
	</div>
	<?php $form = $this->beginWidget('CActiveForm',array(
		'id'=>'add_tags',
		)); ?>

		<div class="add_label form"> <strong><?php echo $form->labelEx($model, 'taglist')?></strong>
			<?php echo $form->textField($model,'taglist');?>
			<span class="add_but" onclick="$('#add_tags').submit();">添加</span>
			<div class="clear"></div> 
			<p style="padding-left:75px;"><?php echo $form->error($model, 'taglist');?></p>
			<style type="text/css">
			.errorMessage{ padding-left:75px;}
			</style>
		</div>
		<?php $this->endWidget(); ?>
		<?php if($_GET['type']!=1):?>
		<div class="hot_label">
			<h2>热门标签：</h2>
			<p>
				<?php foreach((array)$hot_tags as $v):?>
				<span class='fav_t' tag="<?php echo $v[0];?>" st="<?php echo $v[1];?>"><?php echo $v[1];?>, </span>
			<?php endforeach;?>
		</p>
		
		<p>（单击添加）</p>
	</div>
	<div class="recommend_label">
				<h2>推荐标签：</h2>
				<?php $cnams = Tags::className(); foreach((array)$forword_tags as $k=>$v):?>
				<p><strong><?php echo $cnams[$k];?>：</strong>
					<?php foreach((array)$v as $vs):?>
				<span class='fav_t' tag="<?php echo $vs[0];?>" st="<?php echo $vs[1];?>"><?php echo $vs[1];?>, </span>
					<?php endforeach;?>
				</p>
				<?php endforeach;?>
				
			</div>
<?php endif;?>
</div>
<div class="guide_first"><span class="skip" <?php if($_GET['type']==1):?>onclick="location.href='?r=reg/profile'"<?php else:?>onclick="location.href='?r=reg/tags&type=1'"<?php endif;?>>下一步</span></div> 
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
	
	$('.fav_t').click(function(){
		var ids = $(this).attr('tag');
	var st =$(this).attr('st');
			$.post('?r=tags/add',{id:$(this).attr('tag')},
				function(data){
					data = $.parseJSON(data);
					if(data.status=='0'){
						var tmp="<span tag='"+ids+"'> &nbsp;"+st+"</span>";
						$('#mytags').after(tmp);

					}
					else alert(data.desc);
				});
	})
})
</script>